#!/bin/sh

header_html()
{
[ "$FORM_app" = "home" ] && extra_tpl_js=`echo "$extra_tpl_js" && cat <<'EOF'  #首页状态刷新
var refreshbrand;
refreshbrand = setInterval("refresh_short_info()", 10000);
function refresh_short_info()
{
  var url = '/index.cgi?app=home&action=main_status';
  Ha.common.ajax(url, 'html', '', 'get', '', function(data){
    $('#refresh_short_info').html(data);
  }, 1);
};
refresh_short_info();
EOF
`

extra_tpl_css=`echo "$extra_tpl_css" && cat <<'EOF'   # 添加导航样式
.pure-menu li:hover { background: #7f8c8d; }

.pure-menu li:hover > ul {
    display: block;
    top: 0;
    left: 100%;
    visibility: visible;
}

.pure-menu li .pure-menu-children { border: 1px solid #b7b7b7; }

.pure-menu-horizontal > ul > li:hover > ul {
    top: 100%;
    left: 0;
}
EOF
`
extra_tpl_css=`echo "$extra_tpl_css" && cat <<'EOF'   # 网络状态栏样式
.progressdown
{
position:relative;
bottom :6px
}
/*purecss 按钮*/
.button-success {
background: rgb(28, 184, 65); /* this is a green */
}
.button-error {
background: rgb(202, 60, 60); /* this is a maroon */
}
.button-warning {
background: rgb(223, 117, 20); /* this is an orange */
}
.button-secondary {
background: rgb(66, 184, 221); /* this is a light blue */
}
EOF
`

extra_tpl_css=`echo "$extra_tpl_css" && cat <<'EOF'   # 手机端往下挪一些
@media (max-width: 640px) {
  .pure-g{
	padding-top: 50px
  }
}
EOF
`

cat <<EOF

<!doctype html>
<html>
<head>
    <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="A layout example that shows off a responsive product landing page.">

    <title>首页 &ndash; ShellGui &ndash; Router Version</title>

<link rel="stylesheet" href="/apps/home/common/css/pure-min.css">
<link rel="stylesheet" href="/apps/home/common/css/common.css">

<!--[if lte IE 8]>
  
    <link rel="stylesheet" href="http://yui.yahooapis.com/pure/0.5.0/grids-responsive-old-ie-min.css">
  
<![endif]-->
<!--[if gt IE 8]><!-->
  
    <link rel="stylesheet" href="/apps/home/common/css/grids-responsive-min.css">
  
<!--<![endif]-->
  
    <!--[if lte IE 8]>
        <link rel="stylesheet" href="css/layouts/marketing-old-ie.css">
    <![endif]-->
    <!--[if gt IE 8]><!-->
        <link rel="stylesheet" href="/apps/home/common/css/marketing.css">
    <!--<![endif]-->

	<script src="/apps/home/common/js/jquery.min.js" type="text/javascript"></script>
	<script src="/apps/home/common/js/common.js" type="text/javascript"></script>

<script>
$extra_tpl_js
</script>
<style>
$extra_tpl_css
</style>
</head>
EOF

cat <<EOF			# 通知样式
<body>
<div class="notification-bar ajax-notification-bar"><a href="javascript:;" class="close">&times;</a></div>
EOF

cat <<EOF			# 导航条

<div class="header">
    <div class="home-menu pure-menu pure-menu-open pure-menu-horizontal pure-menu-fixed">

        <a class="pure-menu-heading" href="/">首页</a>
EOF
[ "$FORM_app" != "home" ] && cat <<EOF
        <a class="pure-menu-heading">$FORM_app</a>
EOF

cat <<EOF
        <ul>
            <li class="pure-menu-selected"><a href="#">应用市场</a></li>

                    <li class="pure-menu-can-have-children">
                        <a class="pure-menu-label" href="#">$lang</a>
                        <ul class="pure-menu-children">
EOF
. /usr/share/libubox/jshn.sh
json_cleanup
json_init
json_load "`cat /tmp/home.json`"
json_select i18n
json_select app
json_get_keys langs $FORM_app
langs=`echo "$langs" | sed 's/_/-/g'`
for lang_choise in $langs
do
[ "${lang_choise}" != "$lang" ] && cat <<EOF
<li><a a href="index.cgi?app=home&action=change&lang=${lang_choise}">${lang_choise}</a></li>
EOF
done
cat <<EOF
                        </ul>
                    </li>

            <li><a href="index.cgi?app=login&action=post_logout">登出</a></li>		
			
        </ul>
    </div>
</div>
EOF

[ "$FORM_app" = "home" ] && cat <<EOF
<div class="splash-container">
    <div class="splash">
        <h1 class="splash-head">ShellGui路由系统</h1>
        <p class="splash-subhead">
             深圳市涡轮派科技有限公司版权所有
        </p>
        <p>
            <a href="/index.cgi?app=wan" class="pure-button pure-button-primary">wan设置</a>
        </p>
    </div>
</div>
<div class="content-wrapper">
EOF
}

footer_html()
{
cat <<EOF
    <div class="footer l-box is-center" `[ "$1" = "keep_bottom" ] && echo 'style="position:absolute;bottom:0;width:100%;"'`>
	<a style="text-decoration:none;color:white;" href="https://www.shellgui.com/">关于ShellGui</a>|
	<a style="text-decoration:none;color:white;" href="https://www.shellgui.com/">联系我们</a>|
	<a style="text-decoration:none;color:white;" href="https://www.turbopi.com/">服务协议</a>|  涡轮派科技有限公司版权所有
    </div>
</div>


</body>
</html>
EOF
}
